<<<<<<< HEAD
import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    count: 6,
    cart: JSON.parse(localStorage.cart || '')
  },
  mutations: {
    addCart(state, obj) {
      let flag = false
      console.log(obj.goodsinfo.id)
      state.cart.forEach(item => {
        if (item.id === obj.goodsinfo.id) {
          item.count += obj.goodsinfo.count
          flag = true
        }
        localStorage.cart = JSON.stringify(state.cart)
      })
      if (!flag) {
        state.cart.push(obj.goodsinfo)
      }
    }
  },
  getters: {
    getAllCount(state) {
      let c = 0
      state.cart.forEach(el => {
        c += el.count
      })
      return c
    },
    getAllPrice(state) {
      let sum = 0
      // let a = state.cart[0]
      // console.log(a)
      state.cart.forEach(item => {
        // console.log(item.selected);
        if (item.selected) {
          sum += item.price * item.count
        }
      })
      return sum
    }
  }
})
=======
import Vue from "vue";
import Vuex from "vuex"

Vue.use(Vuex)


export const store = new Vuex.Store({
  state: {
    //img price count shopname kucun
    shop: ''
  },
  mutations: {

  }
})
>>>>>>> detail
